{% include "content.html" %}
<html>
  <head>
    <script type="text/javascript">
      window.addEventListener("keypress", logKey);
      function logKey(e) {
        if (e.key == "a") window.location.href = "{{prev_url}}";
        if (e.key == "d") window.location.href = "{{next_url}}";
      }
    </script>
  </head>
  <body>
    <!-- Pagination Links-->
    <div class="text-right">
      {% if prev_url %}
      <a
        href="{{ prev_url}}"
        class="btn btn-outline-dark {% if entries.page == 1 %}disabled{% endif %}"
      >
        &laquo;
      </a>
      {% endif %}
      <!-- Loop through the number of pages to display a link for each-->
      {% for page_num in entries.iter_pages(left_edge=1, right_edge=1,
      left_current=1, right_current=2) %} {% if page_num %}
      <!-- Check for the active page and set the link to "Active"-->
      {% if entries.page == page_num %}
      <a href="{{ url_for('topic', page=page_num) }}" class="btn btn-dark">
        {{ page_num }}
      </a>
      {% else %}
      <a
        href="{{ url_for('topic', page=page_num) }}"
        class="btn btn-outline-dark"
      >
        {{ page_num }}
      </a>
      {% endif %} {% else %} ... {% endif %} {% endfor %} {% if next_url %}
      <a
        href="{{next_url}}"
        class="btn btn-outline-dark {% if entries.page == entries.pages %}disabled{% endif %}"
      >
        &raquo;
      </a>
      {% endif %}
    </div>
    <p class="text-right mt-3">
      Showing page {{ entries.page }} of {{ entries.pages }}
    </p>
  </body>
</html>
